Field of the Invention
Embodiments of the present invention relate generally to graphics processing and, more specifically, to stencil-then-cover path rendering with shared edges.
Description of the Related Art
Path rendering is a style of resolution-independent 2-dimensional rendering, often called “vector graphics,” that is the basis for a number of important rendering standards. Those standards include Postscript, Java 2D, Apple's Quartz 2D, OpenVG, PDF, TrueType fonts, OpenType fonts, PostScript fonts, HTML 5 Canvas, Scalable Vector Graphics (SVG) web format, Microsoft's Silverlight and Adobe Flash. for interactive web experiences, Microsoft's XML Specification (XPS), drawings in Office file formats including PowerPoint, Adobe Illustrator illustrations, and more.
In path rendering, a software application typically specifies a scene as a sequence of resolution-independent outlines, known as paths, that may be painted with constant colors, linear or radial gradients, or images. Many graphics processing units (GPUs) support rendering such paths through a two-pass rendering process known as “stencil-then-cover.” First, in a path stenciling pass, the GPU generates a stencil buffer that indicates which samples (i.e., positions within each pixel) are covered by the path. Second, in a path covering pass, the GPU generates cover geometry for the path and shades the cover geometry with stencil testing enabled. Typically, the GPU implements the cover geometry with some sort of conservative bounding geometry, such as a bounding box (i.e., two triangles), a convex hull, or a similar construct. Because stencil testing is enabled during the path covering pass, the GPU discards any fragments that are not covered by the path and writes the surviving fragments to the color buffer as processed graphics data.
In some approaches to stencil-then-cover path rendering, the GPU maintains N coverage samples per pixel and M color samples per pixel, where N is greater than M. In operation, the GPU determines the coverage of the path at N coverage samples per pixel. Then, during the path covering pass, before the GPU performs blending and color write operations, the GPU reduces the number of coverage samples to the number of color samples. Notably, during this reduction operation, the GPU may select a group of N/M coverage samples associated with a single color sample and generate an opacity value for the color sample based on the proportion of the N/M coverage samples that are covered. One limitation of this rendering approach is that reducing groups of multiple coverage samples to single color samples may introduce conflation artifacts at edges that are shared between different paths. In particular, the reduction operation conflates the boolean concept of coverage with a fractional value for opacity.
For example, suppose that there were 4 coverage samples corresponding to each color sample (N=4 and M=1), the background color were blue, and the GPU were to be configured to render a yin-yang symbol—yin portion first. Further, suppose that the yin portion of the symbol were yellow, the yang portion of the symbol were green, and the yin and yang portions were to share an edge at the boundary between the two portions. Finally suppose that two of the coverage samples associated with a particular color sample were covered by the yellow yin portion of the symbol, and two of the coverage samples associated with the particular color sample were covered by the green yang portion of the symbol. Upon rendering the yin portion of the symbol, the GPU would assign an intermediate blue-tinged color to the particular color sample—a blend of 50% of the yellow color associated with the yin portion of the symbol and 50% of the blue color associated with the background. Subsequently, upon rendering the yang portion of the symbol, the GPU would assign a different blue-tinged color to the particular color sample—a blend of 50% of the green color associated with the yang portion of the symbol and 50% of the intermediate blue-tinged color. Such background color bleeding would degrade the quality of the displayed image. In particular, a fraction of the blue background color would be visible at the boundary between the yin and yang portions of the yin-yang symbol (as if there were a gap between the yin and yang portions of the yin-yang symbol.)
In one approach to reducing the conflation artifacts associated with edges shared between different paths, the number of color samples is increased to match the number of coverage samples. In such implementations, the coverage is maintained separately for each color sample as a Boolean value and is not conflated with opacity. Consequently, rendering scenes that include edges that are shared between different paths does not introduce conflation artifacts attributable to these shared edges. However, increasing the number of color samples increases both the memory consumption and the memory bandwidth used by the color buffer. Because both the local memory capacity of GPUs and the associated memory bandwidth is limited, any increase in either memory consumption or memory bandwidth use is generally undesirable.
Accordingly, what is needed in the art is a more effective approach to rendering edges that are shared between different paths.